
<!DOCTYPE html>

<html>

<head>
    <title>Ceph</title>

    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <link rel="stylesheet"
          href="{{ url_prefix }}/static/AdminLTE-2.3.7/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet"
          href="{{ url_prefix }}/static/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet"
          href="{{ url_prefix }}/static/AdminLTE-2.3.7/dist/css/AdminLTE.min.css">
    <link rel="stylesheet"
          href="{{ url_prefix }}/static/AdminLTE-2.3.7/dist/css/skins/skin-blue.min.css">
    <link rel="stylesheet"
          href="{{ url_prefix }}/static/AdminLTE-2.3.7/plugins/datatables/jquery.dataTables.min.css">

    <script src="{{ url_prefix }}/static/AdminLTE-2.3.7/plugins/jQuery/jquery-2.2.3.min.js"></script>
    <script src="{{ url_prefix }}/static/AdminLTE-2.3.7/plugins/sparkline/jquery.sparkline.min.js"></script>

    <script src="{{ url_prefix }}/static/libs/rivets/0.9.6/rivets.bundled.min.js"></script>
    <script src="{{ url_prefix }}/static/libs/underscore.js/1.8.3/underscore-min.js"></script>

    <script src="{{ url_prefix }}/static/AdminLTE-2.3.7/bootstrap/js/bootstrap.min.js"></script>
    <script src="{{ url_prefix }}/static/AdminLTE-2.3.7/dist/js/app.min.js"></script>
    <script src="{{ url_prefix }}/static/AdminLTE-2.3.7/plugins/datatables/jquery.dataTables.min.js"></script>

    <script src="{{ url_prefix }}/static/libs/moment.js/2.17.1/moment.min.js"></script>
    <script src="{{ url_prefix }}/static/libs/Chart.js/2.4.0/Chart.min.js"></script>

      <script>
        $(document).ready(function(){
            var toplevel_data = {{ toplevel_data }};
            var refresh_interval = 5000;

            var refresh = function() {
                $.get("{{ url_prefix }}/toplevel_data", function(data) {
                    _.extend(toplevel_data, data);
                    setTimeout(refresh, refresh_interval);
                });
            };

            rivets.configure({
                preloadData: true,
                prefix: "rv",
                templateDelimiters: ["{", "}"]
            });

            rivets.formatters.health_color = function(status_str) {
                if (status_str == "HEALTH_OK") {
                    return "color: #00bb00;";
                } else if (status_str == "HEALTH_WARN") {
                    return "color: #FFC200;";
                } else if (status_str == "HEALTH_ERR") {
                    return "color: #ff0000;"
                }
            }

            rivets.formatters.health_ok = function(status_str) {
                if (status_str == "HEALTH_OK") {
                    return true;
                } else {
                    return false;
                }
            }

            var truncate = function(n, max_width) {
                var stringized = n.toString();
                var parts = stringized.split(".");
                if (parts.length == 1) {
                    // Just an int
                    return stringized;
                } else {
                    var fractional_digits = max_width - parts[0].length - 1;
                    if (fractional_digits <= 0) {
                        // No width available for the fractional part, drop
                        // it and the decimal point
                        return parts[0];
                    } else {
                        return stringized.substring(0, max_width);
                    }
                }
            }

            var format_number = function(n, divisor, units) {
                var width=4;
                var unit = 0;

                if (n == null) {
                    // People shouldn't really be passing null, but let's
                    // do something sensible instead of barfing.
                    return "-";
                }

                while (Math.floor(n / (divisor**unit)).toString().length > width - 1) {
                    unit = unit + 1;
                }

                var truncated_float;
                if (unit > 0) {
                    truncated_float = truncate((n / Math.pow(divisor, unit)).toString(), width);
                } else {
                    truncated_float = truncate(n, width);
                }

                return truncated_float + units[unit];
            }

            rivets.formatters.dimless = function(n){
                return format_number(n, 1000, [' ', 'k', 'M', 'G', 'T', 'P'])
            };
            rivets.formatters.dimless_binary = function(n){
                return format_number(n, 1024, ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB']);
            };

            rivets.formatters.block_health_color = function(rbd_mirroring) {
                if (rbd_mirroring.errors > 0) {
                    return "color: #ff0000";
                } else if (rbd_mirroring.warnings > 0) {
                    return "color: #ffc200";
                }
                return "";
            };

            rivets.formatters.short_version = function(version) {
                // Expect "ceph version 1.2.3-g9asdasd (as98d7a0s8d7)"
                var result = /ceph version\s+([^ ]+)\s+\(.+\)/.exec(version);
                if (result) {
                    // Return the "1.2.3-g9asdasd" part
                    return result[1];
                } else {
                    // Unexpected format, pass it through
                    return version;
                }
                return
            };

            /* This is useful if you need to display some alternative text
             * when a collection is empty using rv-hide */
            rivets.formatters.length = function(val) {
              return val.length;
            }

            rivets.formatters.hide_count_box = function(value) {
                value = +value
                return (isNaN(value) || value == 0)
            };

            rivets.bind($("#health"), toplevel_data);
            rivets.bind($("section.sidebar"), toplevel_data);
            setTimeout(refresh, refresh_interval);
        });
      </script>

      <link rel="shortcut icon" href="https://ceph.com/wp-content/themes/cephTheme/Resources/Favicons/favicon-96x96.png">
      <link rel="shortcut icon" href="{{ url_prefix }}/static/favicon.ico">

    <style>
        div.box {
            background-color: #222d32;
            color: #fff;
        }

        div.info-box {
            background-color: #222d32;
            color: #fff;
        }

        .box {
            border-top-color: #b8c7ce;
        }

        div.box-header {
            color: #b8c7ce;
        }

        a.logo {
            background-color: #222d32;
        }

        body {
            background-color: #222d32;
        }

        .navbar {
            background-color: #222d32;
            color: #222d32;
        }

        div#content {
            background-color: #424d52;
            color: #ddd;
        }

        div.progress-bar {
            border-width: 1px;
            border-color: #ddd;
        }

        .ceph-log {
            font-family: monospace;
            background-color: #333;
            color: #ddd;
        }

        .nav-tabs>li.active>a {
            background-color: #424d52;
            color: #ddd;
        }

        .navbar a {
            color: #b8c7ce;
        }

        .ceph-none-found {
            color: #8aa4af;
            font-style: italic;
            padding-left: 15px;
            padding-right: 5px;
            padding-top: 5px;
            padding-bottom: 5px;
        }

        table.ceph-chartbox {
            margin-left: 40px;
        }

        .ceph-chartbox td {
            padding-left: 35px;
            text-align: center;
            font-weight: bold;
        }

        .chart-container {
            width: 100%;
            height: 100%;
        }

        .dataTables_wrapper .dataTables_filter {
            color: #ddd
        }

        .dataTables_wrapper .dataTables_filter input {
            color: #222d32
        }

        .dataTables_wrapper tbody td {
            background-color: #424d52;
            color: #ddd;
        }

        .dataTables_wrapper .dataTables_paginate .ellipsis {
            color: #ddd !important
        }

        .dataTables_wrapper .dataTables_paginate .paginate_button {
            color: #ddd !important
        }

        .dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
            color: #424d52 !important
        }

        .nav-tabs-custom {
            background-color: #222d32;
            color: #ddd;
        }
        .nav-tabs-custom>.nav-tabs>li{
            margin-right: 0;
        }
        .nav-tabs-custom>.nav-tabs>li>a{
            border-bottom-color: transparent;
            color: #aaa;
        }
        .nav-tabs-custom>.nav-tabs>li.active>a{
            background-color: #424d52;
            color: #eee;
        }
        .nav-tabs-custom>.nav-tabs>li.active:hover>a{
            background-color: #66777f;
            color: #eee;
        }
        .nav-tabs-custom>.tab-content {
            background-color: #424d52;
            color: #eee;
        }

    </style>

</head>

<body class="hold-transition sidebar-mini sidebar-collapse">
<div class="wrapper">

    <!-- Main Header -->
    <header class="main-header">
        <!-- Logo -->
        <a href="{{ url_prefix }}/" class="logo">
      <span class="logo-lg">
        <img src="{{ url_prefix }}/static/Ceph_Logo_Standard_RGB_White_120411_fa.png"
             width="123px" height="34px"/>
          </span>
      <span class="logo-mini">
        <img src="{{ url_prefix }}/static/logo-mini.png"
             width="34px" height="34px"/>
          </span>
        </a>

        <!-- Header Navbar -->
        <nav class="navbar navbar-static-top" role="navigation">
            <!-- Sidebar toggle button-->
            <a href="#" class="sidebar-toggle" data-toggle="offcanvas"
               role="button">
                <span class="sr-only">Toggle navigation</span>
            </a>

            <div id="health" style="font-size: 18px; padding: 12px 12px;">
                <span rv-hide="health_status | health_ok" >
                    <span rv-style="health_status | health_color">
                        {health_status}
                    </span>
                </span>
            </div>

            <!-- Navbar Right Menu -->
            <div class="navbar-custom-menu">
                <ul class="nav navbar-nav">

                </ul>
            </div>
        </nav>
    </header>
  <!-- Left side column. contains the logo and sidebar -->
  <aside class="main-sidebar skin-blue">

    <!-- sidebar: style can be found in sidebar.less -->
    <section class="sidebar">
      <!-- Sidebar Menu -->
      <ul class="sidebar-menu">
        <!-- Optionally, you can add icons to the links -->
        <li class="{%if path_info=='/' or path_info.startswith('/health')%}active{%endif%}">
            <a href="{{ url_prefix }}/health">
            <i class="fa fa-heartbeat" rv-style="health_status | health_color"></i>
            <span>Cluster health</span></a>
        </li>
        <li class="treeview{%if path_info.startswith(('/server', '/osd','/config_options'))%} active{%endif%}">
          <a href="#"><i class="fa fa-server"></i> <span>Cluster</span>
            <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
          </a>
          <ul class="treeview-menu menu-open">
            <li>
                <a href="{{ url_prefix }}/servers">Servers</a>
            </li>
            <li>
                <a href="{{ url_prefix }}/osd">OSDs</a>
            </li>
	    <li>
              <a href="{{ url_prefix }}/config_options">Configuration</a>
            </li>
          </ul>
        </li>
        <li class="treeview{%if path_info.startswith('/rbd')%} active{%endif%}">
          <a href="#">
            <i class="fa fa-hdd-o" rv-style="rbd_mirroring | block_health_color"></i> <span>Block</span>
            <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
          </a>
          <ul class="treeview-menu menu-open">
            <li>
              <a href="{{ url_prefix }}/rbd_mirroring">
                <i class="fa fa-exchange"></i> Mirroring
                <span class="pull-right-container">
                    <small rv-hide="rbd_mirroring.warnings | hide_count_box" class="label pull-right bg-yellow">{rbd_mirroring.warnings}</small>
                    <small rv-hide="rbd_mirroring.errors | hide_count_box" class="label pull-right bg-red">{rbd_mirroring.errors}</small>
                </span>
              </a>
            </li>
            <li>
              <a href="{{ url_prefix }}/rbd_iscsi">
                <i class="fa fa-upload"></i> iSCSI
                <span class="pull-right-container" />
              </a>
            </li>
            <li class="treeview{%if path_info.startswith('/rbd_pool')%} active menu-open{%endif%}">
              <a href="#">
                <i class="fa fa-dot-circle-o"></i> <span>Pools</span>
                <span class="pull-right-container">
                  <i class="fa fa-angle-left pull-right"></i>
                </span>
              </a>
              <ul class="treeview-menu">
                <li rv-each-pool="rbd_pools">
                  <a rv-href="pool.url"><i class="fa fa-circle-o"></i> {pool.name}</a>
                </li>
                <li class="ceph-none-found" rv-hide="rbd_pools | length">None found</li>
              </ul>
            </li>
          </ul>
        </li>
        <li class="treeview{%if path_info.startswith(('/filesystem/', '/clients/'))%} active{%endif%}">
          <a href="#"><i class="fa fa-folder"></i> <span>Filesystems</span>
            <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
          </a>
          <ul class="treeview-menu menu-open">
            <li rv-each-filesystem="filesystems">
                <a rv-href="filesystem.url">{filesystem.name}</a>
            </li>
            <li class="ceph-none-found" rv-hide="filesystems | length">None found</li>
          </ul>
        </li>
      </ul>
      <!-- /.sidebar-menu -->
    </section>
    <!-- /.sidebar -->
  </aside>

  <div id="content" class="content-wrapper">

      {% block content %}{% endblock %}

  </div>
  <!-- /.content-wrapper -->

  <!-- Main Footer -->
  <footer class="main-footer">
    <!-- To the right -->
    <div class="pull-right hidden-xs">
      {{ ceph_version }}
    </div>
    <!-- Default to the left -->
    <strong>Copyright &copy; 2016 by Ceph Contributors.</strong> Free software (LGPL 2.1)
  </footer>

</div>

<!--
<pre>
{{ data }}
</pre>
-->

<!-- Bootstrap 3.3.6 -->

<!-- AdminLTE App -->


</body>
</html>
